﻿@model IEnumerable<ArivisTests.Models.TestCase>
@using ArivisTests.Views;

@{
    int numTests = Model.Count();
    var groups = Model.GroupBy(x => x.Result).OrderBy(x => x.Key).ToList();
    int colWidth = 100 / groups.Count;
}

<table class="display-table">
<tr>
@foreach (var group in groups)
{
    <th style="width:@(colWidth)%">@MvcHtmlString.Create(group.Key == null ? "[no result]" : group.Key.Name)</th>
}
</tr>
<tr>
@foreach (var group in groups)
{
    int groupTests = group.Count();
    int percent = 100 * groupTests / numTests;
    <td class="display-field">@(percent)% (@groupTests / @numTests)</td>
}
</tr>

<tr>
@foreach (var group in groups)
{
    int groupTests = group.Count();
    int percent = 100 * groupTests / numTests;
    <td style="vertical-align:text-top">
        <div style="max-height: 350px; overflow-y:auto">
        @Html.LinkedItems("Edit", "TestCase", group.OrderBy(test => test.Order), true)
        </div>
    </td>
}
</tr>

</table>
